'use strict'

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller, io } = app

  router.post('/home', controller.home.index)

  router.post('/user/login', controller.user.login)
  router.post('/user/register', controller.user.register)
  router.get('/user/checkLogin', controller.user.checkLogin)
  router.get('/user/userInfo', controller.user.getUserInfo)
  router.post('/user/userInfo', controller.user.updateUserInfo)
  router.get('/user/:userId/profile', controller.user.getUserProfile)

  router.post('/login', controller.chat.login);
  router.post('/chat', controller.chat.getChatList);
  router.post('/chat2', controller.chat.getChatList2);
  router.post('/history', controller.chat.getHistory);

  router.post('/chat/search-user', controller.chat.searchUser);
  router.post('/chat/getFriendList', controller.chat.getFriendList)
  router.post('/chat/getNewFirentNotice', controller.chat.getNewFirentNotice)

  router.post('/chat/createRoom', controller.room.createRoom)     // 创建群组
  router.post('/chat/getRoomList', controller.room.getRoomList)   // 获取群组列表
  router.post('/chat/getRoomUserList', controller.room.getRoomUserList) 
  
  router.get('/chat/:partnerId', controller.chat.show)

  io.of('/').route('online', io.controller.chat.online)                   // 上线通知
  io.of('/').route('news', io.controller.chat.news)                       // 私发消息
  io.of('/').route('room-news', io.controller.chat.roomNews)              // 群发消息
  io.of('/').route('receiveAllMsg', io.controller.chat.receiveAllMsg)
  io.of('/').route('friendApply', io.controller.chat.friendApply)         // 好友申请
  io.of('/').route('dealFriendApply', io.controller.chat.dealFriendApply) // 好友申请
  io.of('/').route('ack', io.controller.chat.ack)
}
